package com.mayikt.edu.aop;

import com.mayikt.edu.base.BaseApiController;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * @author 余胜军 @ClassName LogException
 */
@Aspect
@Component
@Slf4j
public class LogExceptionAop extends BaseApiController {
  /**
   * aop环绕通知
   *
   * @param pjp
   * @return
   * @throws Throwable
   */
  @Around(value = "execution(public * com.mayikt.edu.controller..*.*(..))")
  public Object currentLimit(ProceedingJoinPoint pjp) throws Throwable {

    try {
      // 目标方法
      return pjp.proceed();
    } catch (Exception e) {
      log.error("e:{}", e);
      return setResultError();
    }
  }
}
